
public class Test {
    public static void main(String[] args) {
        Person<String> p1 = new Person<>("唱跳rap");
        System.out.println("p1'get_some_info is " + p1.get_some_info());

        Person<Integer> p2 = new Person<>(233);
        System.out.println("p2'get_some_info is " + p2.get_some_info());

        Person<String> p3 = Person.create("打篮球");
        System.out.println("p3'get_some_info is " + p3.get_some_info());

        System.out.println(p1.do_return(111));
        System.out.println(p1.do_return("456"));
    }

}

// 1、类的泛型
class Person<T> {
    T some_info;

    Person(T some_info) {
        this.some_info = some_info;
    }

    // 2、成员函数泛型
    public T get_some_info() {
        return this.some_info;
    }

    // 3、静态方法的泛型
    public static <K> Person<K> create(K init) {
        return new Person<K>(init);
    }

    // 3、成员独立函数泛型（函数需要的类型和class不一致）
    <U> U do_return(U u1) {
        return u1;
    }
}